<template>
    <div>
预警级别定性：
    轻度：<el-select v-model="lowlevel" placeholder="1次" clearable>
    <el-option label="1次" value="1" />
    <el-option label="2次" value="2" />
</el-select>
    中度：<el-select v-model="middellevel" placeholder="3次" clearable>
    <el-option label="3次" value="3" />
    <el-option label="4次" value="4" />
</el-select>
    重度：<el-select v-model="highlevel" placeholder="5次" clearable>
    <el-option label="5次" value="5" />
    <el-option label="6次" value="6" />
    <el-option label="7次" value="7" />
    <el-option label="8次" value="8" />
</el-select>
    <el-button type="success" @click="sendLevel()">确定</el-button>
    </div>
    <div>
预警触发条件：
绩点：<el-input placeholder="2.0" v-model="gredit" type="text" style="width:200px"/>
        <el-button type="success" @click="sendCondition()">确定</el-button>
    </div>
    <div>
预警发送方式：<el-select v-model="method" placeholder="系统信息" clearable>
        <el-option label="系统信息" value="systemValue" />
        <el-option label="邮件" value="email" />
    </el-select>
        <el-button type="success" @click="sendMethod()">确定</el-button>
    </div>
</template>
<script setup>
import { get,post } from '@/utils/request.js'
import {ElMessage} from 'element-plus'
import { ref,onMounted } from 'vue'
import moment from 'moment'

const lowlevel=ref(1)
const middellevel=ref(3)
const highlevel=ref(5)
const gredit=ref('2')
const method=ref('')

const getSetting=()=>{
  get('/setting/getSetting', (message) => {
    lowlevel.value = message[0]
    middellevel.value = message[1]
    method.value = message[2]
    gredit.value = message[3]
  }, (message) => {
    ElMessage.warning(message)
  })
}

onMounted(async () => {
  getSetting()
})

const sendLevel=()=>{
post('/setting/level',{
lowlevel:lowlevel.value,
middellevel:middellevel.value,
highlevel:highlevel.value
},(message)=>{
  getSetting()
ElMessage.success(message)
},(message)=>{
  getSetting()
ElMessage.warning(message)
})
}

const sendCondition=()=>{
post('/setting/condition',{
gredit:gredit.value
},(message)=>{
  getSetting()
ElMessage.success(message)
},(message)=>{
  getSetting()
ElMessage.warning(message)
})
}

const sendMethod=()=>{
post('/setting/condition',{
method:method.value
},(message)=>{
  getSetting()
ElMessage.success(message)
},(message)=>{
  getSetting()
ElMessage.warning(message)
})
}

</script>
<style scoped>
</style>